package web.zipcode;

import java.sql.SQLException;

import java.util.ArrayList;

import javax.naming.NamingException;

public class ZipcodeControl {

    private ZipcodeDAOOracle getDAOOracle() throws ZipcodeException {

        try {

            return new ZipcodeDAOOracle();

        } catch ( NamingException ne ) {

            throw new ZipcodeException( ne.getMessage() );

        } // end try~catch

    } // end method

    public ArrayList searchByDong( String dong ) throws ZipcodeException {

        ZipcodeDAOOracle daoDB = getDAOOracle();

        try {

            return daoDB.searchByDong( dong );

        } catch ( SQLException sqle ) {

            throw new ZipcodeException( sqle.getMessage() );

        } // end try~catch

    } // end method

    public ArrayList searchAllSido() throws ZipcodeException {

        ZipcodeDAOOracle daoDB = getDAOOracle();

        try {

            return daoDB.searchAllSido();

        } catch ( SQLException sqle ) {

            throw new ZipcodeException( sqle.getMessage() );

        } // end try~catch

    } // end method

    public ArrayList searchAllGugun( String sido ) throws ZipcodeException {

        ZipcodeDAOOracle daoDB = getDAOOracle();

        try {

            return daoDB.searchAllGugun( sido );

        } catch ( SQLException sqle ) {

            throw new ZipcodeException( sqle.getMessage() );

        } // end try~catch

    } // end method

    public ArrayList searchAllDong( String sido, String gugun ) throws ZipcodeException {

        ZipcodeDAOOracle daoDB = getDAOOracle();

        try {

            return daoDB.searchAllDong( sido, gugun );

        } catch ( SQLException sqle ) {

            throw new ZipcodeException( sqle.getMessage() );

        } // end try~catch

    } // end method

} // end class